1633C - Kill the Monster - CodeForces Solution


brute force math *1100

Please click on ads to support us..

Python Code:

I = lambda: map(int, input().split())
for _ in range(int(input())):
    hc,dc=I()
    hm,dm=I()
    k,w,a=I()
    ff=0
    for i in range(k+1):
        minmod=(dc+(k-i)*w+hm-1)//(dc+(k-i)*w)
        maxhc=(hc+i*a+dm-1)//dm
        if maxhc>=minmod:
            ff=1
            break
    print('yneos'[int(ff==0)::2])

C++ Code:

#include <bits/stdc++.h>
using namespace std;
#define easy_love ios::sync_with_stdio(0), cin.tie(nullptr)
#define endl '\n'
#define int long long
#define ar array<int, 2>
#define arr array<int, 3>
int T, n, m, k, inf = 1e18;
int mod = 998244353; //1e9+7;
const int N = 201314;

signed main()
{
    easy_love;
#ifdef DEBUG
    freopen("../1.in", "r", stdin);
#endif
    // 挺费劲的。。
    // 就是 每次升级。。可以用加攻击力 w 或者加护甲a。。。
    // 升级k次。。
    // 问 能否打死怪兽。。。轮流
    // 增加护甲相当于减少怪兽的攻击力。。
    // k是可以枚举的。。
    // 我们可以枚举 k不同分配下的情况。。。
    cin >> T;
    while (T--)
    {
        ar a, b;
        cin >> a[0] >> a[1];
        cin >> b[0] >> b[1];
        cin >> k >> n >> m;
        bool f = 0;
        for (int i = 0; i <= k; ++i)
        {
            int x = a[1] + i * n, y = a[0] + m * (k - i);
            if ((b[0] + x - 1) / x <= (y + b[1] - 1) / b[1])
            {
                f = 1;
                break;
            }
        }
        cout << (f ? "YES" : "NO") << endl;
    }
};


Comments

Submit
0 Comments
More Questions

1029A - Many Equal Substrings
1675D - Vertical Paths
1271C - Shawarma Tent
805A - Fake NP
1163A - Eating Soup
787A - The Monster
807A - Is it rated
1096A - Find Divisible
1430C - Numbers on Whiteboard
1697B - Promo
208D - Prizes Prizes more Prizes
659A - Round House
1492C - Maximum width
171B - Star
1512B - Almost Rectangle
831B - Keyboard Layouts
814A - An abandoned sentiment from past
268C - Beautiful Sets of Points
1391C - Cyclic Permutations
11A - Increasing Sequence
1406A - Subset Mex
1365F - Swaps Again
50B - Choosing Symbol Pairs
1719A - Chip Game
454B - Little Pony and Sort by Shift
1152A - Neko Finds Grapes
1719B - Mathematical Circus
1719C - Fighting Tournament
1642A - Hard Way
285C - Building Permutation